#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>

int main(int argc, char *argv[]){
	int n;
	int edge;
	int i, j, line, row;
	int w;
	int **graph;

	if(argv[1] == NULL || !(n = atoi(argv[1])) || n<3){
		printf("Invalid argument or missing! Use a value between [3, 1000]\n");
		return -1;
	}

	graph = (int**)malloc(n*sizeof(int*));

	for(i=0; i<n; i++){
		graph[i] = (int*)calloc(n, sizeof(int));
	}
	
	srand(time(NULL));

	edge = rand()%((n-2)*(n-1)/2)+n-1;

	printf("%d %d\n", n, edge);

	i=0;
	while(i<edge){
		line = rand()%n;
		row = rand()%n;
		w = rand()%100000;
		if(line != row && graph[line][row] == 0){
			graph[line][row] = w;
			graph[row][line] = w;
			printf("%d %d %d\n", line+1, row+1, w);
			i++;
		}
	}

	for(i=0; i<n; i++){
		free(graph[i]);
	}

	free(graph);
	return 0;
}

